package com.atguigu.ssyx.product.controller;


import com.atguigu.ssyx.common.result.Result;
import com.atguigu.ssyx.product.service.UploadService;
import com.atguigu.ssyx.vo.product.FileVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Api(tags = "文件管理")
@RestController
@RequestMapping("/file")
//@Tag(name = "文件管理")
public class FileController {
    @Autowired
    private UploadService uploadService;

    @PostMapping("upload")
    @ApiOperation("上传文件")
//    @Operation(summary = "上传文件")
    public Result upload(@RequestParam("file") MultipartFile file) throws IOException {
        FileVO upload = uploadService.upload(file);
        return Result.ok(upload);

//        return new Result().ok(upload);
    }

}
